from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage


class AssetPerson(BasePage):
    url = r'/bsams/front/asset/asset_list.do'
    # 修改电话号码
    phone_btn_loc = (By.ID, 'phone')
    phone_ok_loc = (By.CLASS_NAME, 'button_fujian')
    # 修改密码
    password_btn_loc = (By.XPATH, '/html/body/div[1]/div/div[1]/a')
    password_oldPassword_loc = (By.ID, 'oldPassword')
    password_newPassword1_loc = (By.ID, 'newPassword1')
    password_newPassword2_loc = (By.ID, 'newPassword2')
    password_ok_loc = (By.CLASS_NAME, 'button_fujian.margin')

    # 修改电话
    def asset_phone(self, number):
        self.ele_clear(self.phone_btn_loc)
        self.input_ele(self.phone_btn_loc, number)
        self.ele_click(self.phone_ok_loc)
        text = self.get_alert_text()
        self.alert_click()
        return text

    # 修改密码
    def asset_password(self, oldPassword, newPassword1, newPassword2):
        self.ele_click(self.password_btn_loc)
        self.input_ele(self.password_newPassword1_loc, oldPassword)
        self.input_ele(self.password_newPassword1_loc, newPassword1)
        self.input_ele(self.password_newPassword2_loc, newPassword2)
        self.ele_click(self.password_ok_loc)
        text = self.get_alert_text()
        self.alert_click()
        return text


# 修改电话号码
phone_btn_loc = (By.ID, 'phone')
phone_ok_loc = (By.CLASS_NAME, 'button_fujian')
